package flc.ast.utils;

import com.blankj.utilcode.util.GsonUtils;
import com.blankj.utilcode.util.SPUtils;
import com.google.gson.reflect.TypeToken;

import java.util.List;

import flc.ast.bean.MyAlbumBean;
import stark.common.bean.StkResBean;


public class AppSpUtils {
    private static final String SP_NAME = "appCollSp";
    private static final SPUtils sSpUtils = SPUtils.getInstance(SP_NAME);

    public static void saveLikeList(List<StkResBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_like_list, json);
    }

    public static List<StkResBean> getLikeList() {
        String json = sSpUtils.getString(Key.key_like_list);
        return GsonUtils.fromJson(json, new TypeToken<List<StkResBean>>() {
        }.getType());
    }

    public static void saveCollectList(List<StkResBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_collect_list, json);
    }

    public static List<StkResBean> getCollectList() {
        String json = sSpUtils.getString(Key.key_collect_list);
        return GsonUtils.fromJson(json, new TypeToken<List<StkResBean>>() {
        }.getType());
    }

    public static void saveSearchRecordList(List<String> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_search_record_list, json);
    }

    public static List<String> getSearchRecordList() {
        String json = sSpUtils.getString(Key.key_search_record_list);
        return GsonUtils.fromJson(json, new TypeToken<List<String>>() {
        }.getType());
    }

    public static void saveCategoryList(List<MyAlbumBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_video_category_list, json);
    }

    public static List<MyAlbumBean> getCategoryList() {
        String json = sSpUtils.getString(Key.key_video_category_list);
        return GsonUtils.fromJson(json, new TypeToken<List<MyAlbumBean>>() {
        }.getType());
    }

    interface Key {
        String key_like_list = "key_like_list";
        String key_collect_list = "key_collect_list";
        String key_search_record_list = "key_search_record_list";
        String key_video_category_list = "key_video_category_list";
    }
}